<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #app {
            width: 50%;
            height: 300px;
            background-color: #dddddd;
            margin: 0 auto;
        }
    </style>
</head>

<body>
    <div id="app">
        <div>
            <button class="btn">点击获取css样式属性</button>
        </div>

    </div>
</body>
<script>
    let btn = document.querySelector('.btn')
    btn.onclick = function () {
        //元素的css属性
        let width = getComputedStyle(app, null).width
        console.log(width);
        let display = getComputedStyle(app, null).display
        console.log(display);
    }
</script>

</html>